﻿using Microsoft.Extensions.Logging;

namespace DiffuseEnjoyIdle.TimedTaskCentre.Hangfire
{
    public class HangfireManager
    {

        private readonly IEnumerable<IHangfireJob> _jobs;
        private readonly ILogger<HangfireManager> _logger;

        public HangfireManager(IEnumerable<IHangfireJob> jobs
            , ILogger<HangfireManager> logger)
        {
            _jobs = jobs;
            _logger = logger;
        }

        public async Task ExecuteAsync()
        {
            _logger.LogInformation("定时任务启动");

            foreach (var job in _jobs)
            {
              await job.ExecuteAsync();
            }

            await Task.Delay(0);
        }
    }
}
